//
//  UnitList.h
//  MapEdit
//
//  Created by Steven Canfield on 25/06/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "UnitDoodad.h"
#import "Unit.h"
#import "DebugLog.h"
#import "NSMutableDataAdditions.h"

@interface UnitList : NSObject {
	chk_unit_t * units;
	u_int32_t	 unitCount;

	u_int32_t	_nextIdentifier;
	
	NSMutableArray * unitArray;
}
- (id)initWithData:(NSData *)data;
- (NSData *)serializedUnitList;
- (Unit *)unitAtIndex:(int)index;
- (void)addUnitAtX:(int)x Y:(int)y type:(int)type owner:(int)owner;
- (int)unitCount;

/* Sorting */
- (void)sortUnitList;
- (void)swapUnitAtIndex:(int)index withUnit:(int)otherIndex;
- (BOOL)compare:(int)index with:(int)compareIndex;

- (int)indexOfClosestUnitToPoint:(NSPoint)point;
@end
